import bsddb, time
db = bsddb.btopen('/tmp/spam.db')
run = True
i = 0
while run:
    t = time.time()
    db[str(t)] = time.ctime(t)
    while len(db) > 30:
        del db[db.first()[0]]
    db.sync()
    # run = False
    print t, time.ctime(t)
    time.sleep(1)
    i = i + 1
    if i > 60:
        run = False

